package com.person.providerpayment9001.controller;


import com.person.common.CommonResult;
import com.person.providerpayment9001.entity.Payment;
import com.person.providerpayment9001.service.PaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.TimeUnit;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhangfc
 * @since 2021-05-13
 */
@RestController
@RequestMapping("/providerpayment9001/payment")
public class PaymentController {
    @Autowired
    private PaymentService paymentService;
    @Value("${server.port}")
    private String serverPort;

    @PostMapping("/save")
    public CommonResult saveOne(@RequestBody Payment payment) {
        return paymentService.saveOne(payment);
    }

    @GetMapping("/find/{id}")
    public CommonResult findOne(@PathVariable("id") int id){
        int i =1;
        return paymentService.findOne(id,serverPort);
    }

    @PostMapping("/update")
    public CommonResult updateByid(@RequestBody Payment payment){

        return paymentService.updateByid(payment);
    }
    @GetMapping("/gettimeout")
    public CommonResult paymentFeignTimeout(){
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return CommonResult.ok(200,"success",null);
    }
}
